//
//  LJRecommendLogInfoDto.m
//
//  Created by   on 2018/9/28
//  Copyright (c) 2018 __MyCompanyName__. All rights reserved.
//

#import "LJRecommendLogInfoDto.h"


NSString *const kLJRecommendLogInfoDtoFrameId = @"frameId";
NSString *const kLJRecommendLogInfoDtoProjectName = @"projectName";
NSString *const kLJRecommendLogInfoDtoAbTestFlag = @"abTestFlag";
NSString *const kLJRecommendLogInfoDtoExpoId = @"expoId";
NSString *const kLJRecommendLogInfoDtoStrategyName = @"strategyName";


@interface LJRecommendLogInfoDto ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation LJRecommendLogInfoDto

@synthesize frameId = _frameId;
@synthesize projectName = _projectName;
@synthesize abTestFlag = _abTestFlag;
@synthesize expoId = _expoId;
@synthesize strategyName = _strategyName;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict {
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if (self && [dict isKindOfClass:[NSDictionary class]]) {
            self.frameId = [self objectOrNilForKey:kLJRecommendLogInfoDtoFrameId fromDictionary:dict];
            self.projectName = [self objectOrNilForKey:kLJRecommendLogInfoDtoProjectName fromDictionary:dict];
            self.abTestFlag = [self objectOrNilForKey:kLJRecommendLogInfoDtoAbTestFlag fromDictionary:dict];
            self.expoId = [self objectOrNilForKey:kLJRecommendLogInfoDtoExpoId fromDictionary:dict];
            self.strategyName = [self objectOrNilForKey:kLJRecommendLogInfoDtoStrategyName fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.frameId forKey:kLJRecommendLogInfoDtoFrameId];
    [mutableDict setValue:self.projectName forKey:kLJRecommendLogInfoDtoProjectName];
    [mutableDict setValue:self.abTestFlag forKey:kLJRecommendLogInfoDtoAbTestFlag];
    [mutableDict setValue:self.expoId forKey:kLJRecommendLogInfoDtoExpoId];
    [mutableDict setValue:self.strategyName forKey:kLJRecommendLogInfoDtoStrategyName];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description  {
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];

    self.frameId = [aDecoder decodeObjectForKey:kLJRecommendLogInfoDtoFrameId];
    self.projectName = [aDecoder decodeObjectForKey:kLJRecommendLogInfoDtoProjectName];
    self.abTestFlag = [aDecoder decodeObjectForKey:kLJRecommendLogInfoDtoAbTestFlag];
    self.expoId = [aDecoder decodeObjectForKey:kLJRecommendLogInfoDtoExpoId];
    self.strategyName = [aDecoder decodeObjectForKey:kLJRecommendLogInfoDtoStrategyName];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_frameId forKey:kLJRecommendLogInfoDtoFrameId];
    [aCoder encodeObject:_projectName forKey:kLJRecommendLogInfoDtoProjectName];
    [aCoder encodeObject:_abTestFlag forKey:kLJRecommendLogInfoDtoAbTestFlag];
    [aCoder encodeObject:_expoId forKey:kLJRecommendLogInfoDtoExpoId];
    [aCoder encodeObject:_strategyName forKey:kLJRecommendLogInfoDtoStrategyName];
}

- (id)copyWithZone:(NSZone *)zone {
    LJRecommendLogInfoDto *copy = [[LJRecommendLogInfoDto alloc] init];
    
    
    
    if (copy) {

        copy.frameId = [self.frameId copyWithZone:zone];
        copy.projectName = [self.projectName copyWithZone:zone];
        copy.abTestFlag = [self.abTestFlag copyWithZone:zone];
        copy.expoId = [self.expoId copyWithZone:zone];
        copy.strategyName = [self.strategyName copyWithZone:zone];
    }
    
    return copy;
}


@end
